<?php
include_once("match_repository.php");
$repMatch= new MatchRepository;
$playersT1=array($_POST['player1T1'],$_POST['player2T1'],$_POST['player3T1']);
$playersT2=array($_POST['player1T2'],$_POST['player2T2'],$_POST['player3T2']);
$scaduleId=$_POST['scaduleId'];
$playersT1Letter=array($_POST['player1T1Letter'],$_POST['player2T1Letter'],$_POST['player3T1Letter']);
$playersT2Letter=array($_POST['player1T2Letter'],$_POST['player2T2Letter'],$_POST['player3T2Letter']);


for($i=0;$i<3;$i++){
	for($j=0;$j<3;$j++){
		if ($playersT1Letter[$i]=='A'&&$playersT2Letter[$j]=='X')
			$repMatch->updateMatchNumber(1,$scaduleId,$playersT1[$i],$playersT2[$j]);
		else if($playersT1Letter[$i]=='B'&&$playersT2Letter[$j]=='Y')
			$repMatch->updateMatchNumber(2,$scaduleId,$playersT1[$i],$playersT2[$j]);
		else if($playersT1Letter[$i]=='C'&&$playersT2Letter[$j]=='Z')
			$repMatch->updateMatchNumber(3,$scaduleId,$playersT1[$i],$playersT2[$j]);
		else if($playersT1Letter[$i]=='B'&&$playersT2Letter[$j]=='X')
			$repMatch->updateMatchNumber(4,$scaduleId,$playersT1[$i],$playersT2[$j]);
		else if($playersT1Letter[$i]=='A'&&$playersT2Letter[$j]=='Z')
			$repMatch->updateMatchNumber(5,$scaduleId,$playersT1[$i],$playersT2[$j]);
		else if($playersT1Letter[$i]=='C'&&$playersT2Letter[$j]=='Y')
			$repMatch->updateMatchNumber(6,$scaduleId,$playersT1[$i],$playersT2[$j]);
		else if($playersT1Letter[$i]=='B'&&$playersT2Letter[$j]=='Z')
			$repMatch->updateMatchNumber(7,$scaduleId,$playersT1[$i],$playersT2[$j]);
		else if($playersT1Letter[$i]=='C'&&$playersT2Letter[$j]=='X')
			$repMatch->updateMatchNumber(8,$scaduleId,$playersT1[$i],$playersT2[$j]);
		else if($playersT1Letter[$i]=='A'&&$playersT2Letter[$j]=='Y')
			$repMatch->updateMatchNumber(9,$scaduleId,$playersT1[$i],$playersT2[$j]);
	}
}



header('LOCATION:'.$_SERVER["HTTP_REFERER"]);
?>